#include <unistd.h>
#include <mutex>
#include "sys.h"
#include "MainPage.h"

using namespace std;

static void  main_page_exit_callback(lv_event_t *event);

static MainPage *main_page;

int main(void)
{
    sys_init();
    lv_init(); // lvgl gui初始化
    lv_port_disp_init();
    lv_port_indev_init();
    lv_port_fs_init();
    mutex ui_mutex;

    main_page = new MainPage(main_page_exit_callback, ui_mutex);

    while (1)
    {
        ui_mutex.lock();
        lv_task_handler();
        ui_mutex.unlock();

        usleep(5000);
    }
}

/*
 *@brief picture退出回调函数
 */
static void  main_page_exit_callback(lv_event_t *event)
{
    delete main_page;

    exit(0);
}
